import functions from './functions.js';
let config = require('./config.js');
function upload(params = {}) {
	return new Promise((resolve, reject) => {
		uni.chooseImage({
			count: 1,
			sizeType: ['original', 'compressed'],
			sourceType: ['album', 'camera'],
			success(res) {
				const tempFilePaths = res.tempFilePaths;
				functions.loadingToast("上传中...");
				uni.uploadFile({
					url: config.Host + 'platform/config/upload',
					filePath: tempFilePaths[0],
					name: 'file',
					formData: params,
					success(res) {
						const data = res.data
						functions.hideToast();
						resolve(data);
					},
					fail(e) {
						functions.hideToast();
						reject(e);
					}
				})
			}
		})
	})
}
export default upload;
